home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Cream of the Crop 22
/
Cream of the Crop 22.iso
/
program
/
tn2.zip
/
PRIMES.T
< prev
next >
Wrap
Text File
|
1996-11-15
|
810b
|
51 lines
%
% "primes.t" generates all the primes between 0 and 2000
%
% Sample program for the T Interpreter by:
%
% Stephen R. Schmitt
% 962 Depot Road
% Boxborough, MA 01719
%
var prime : int
var rprime : real
var i : int
var sqrtp : int
var notprime : boolean
program
put 2 : 10
put 3 : 10
prime := 5
loop
rprime := prime
sqrtp := round( sqrt( rprime ) + 0.5 )
i := 1
notprime := false
loop
exit when i >= sqrtp or notprime
i := i + 2
notprime := prime mod i = 0
end loop
if not notprime then
put prime : 10
end if
prime := prime + 2
exit when prime > 2000
end loop
end program